﻿@using System.Web.UI.WebControls
@using DevExpress.Web.ASPxClasses
@using DevExpress.Web.ASPxEditors
@using DevExpress.Web.Mvc.UI
@using Dogshow.Model
@using System.Web.Mvc.Html
@using Dogshow.Web.Controllers
@using Dogshow.Web.Utils
@model Pas
@using (Html.BeginForm("AzurirajPsa", "Psi", FormMethod.Post, new { @class = "edit_form" }))
{
    <div id="editors">
        @Html.Hidden("Id", "0", new { id = "Id" })
        <div class="line">
            @Html.DevExpress().HyperLink(s =>
                                       {
                                           s.Name = "btnNoviUnos";
                                           s.Properties.Text = "Novi unos";
                                           s.Properties.ClientSideEvents.Click = "onNoviUnos";
                                           s.Properties.Style.Cursor = "Pointer";
                                       }).GetHtml()
        </div>
        <div class="line">
            @Html.DevExpress().Label(
                            s =>
                            {
                                s.ControlStyle.CssClass = "label";
                                s.Text = "Rasa:";
                                s.AssociatedControlName = "IdRase";
                            }
                        ).GetHtml()
            @Html.PartialOrNull("_RasePasaComboBox", Model.IdRase)
        </div>
        <div class="line">
            @Html.DevExpress().Label(s =>
            {
                s.Text = "Broj rodovnika:";
                s.AssociatedControlName = "BrojRodovnika";
                s.ControlStyle.CssClass = "label";
            }).GetHtml()
            @Html.DevExpress().TextBox(s =>
                                     {
                                         s.Name = "BrojRodovnika";
                                         s.ControlStyle.CssClass = "editor";
                                         s.Properties.ConvertEmptyStringToNull = true;
                                         s.ShowModelErrors = true;
                                         //s.Properties.ClientSideEvents.Validation = "onBrojRodovnikaValidation";
                                     }).Bind(Model.BrojRodovnika).GetHtml()
        </div>
        <div class="line">
            @Html.DevExpress().Label(s =>
           {
               s.Text = "Ime:";
               s.AssociatedControlName = "ImePsa";
               s.ControlStyle.CssClass = "label";
           }).GetHtml()
            @Html.DevExpress().TextBox(s =>
           {
               s.Name = "ImePsa";
               s.ControlStyle.CssClass = "editor";
               s.ShowModelErrors = true;
           }).Bind(Model.ImePsa).GetHtml()
        </div>
        <div class="line">
            @Html.DevExpress().Label(s =>
       {
           s.ControlStyle.CssClass = "label";
           s.Text = "Pol:";
           s.AssociatedControlName = "Pol";
       }).GetHtml()
            @Html.DevExpress().RadioButtonList(s =>
       {
           s.Name = "Pol";
           s.Properties.TextField = "Naziv";
           s.Properties.ValueField = "Id";
           s.Properties.ValueType = typeof(int);
           s.Properties.RepeatDirection = RepeatDirection.Horizontal;
           s.ControlStyle.CssClass = "editor";
           s.ShowModelErrors = true;
       }).BindList(new[] { new { Id = 1, Naziv = "Mužjak" }, new { Id = 2, Naziv = "Ženka" } }).Bind(Model.Pol).GetHtml()
            <div class="line">
                @Html.DevExpress().Label(s =>
            {
                s.Text = "Oštenjen:";
                s.AssociatedControlName = "Ostenjen";
                s.ControlStyle.CssClass = "label";
            }).GetHtml()
                @Html.DevExpress().DateEdit(s =>
            {
                s.Name = "Ostenjen";
                s.ControlStyle.CssClass = "editor";
                s.ShowModelErrors = true;
            }).Bind(Model.Ostenjen).GetHtml()
            </div>
        </div>
        <div class="line">
            @Html.DevExpress().Label(
                        s =>
                        {
                            s.Text = "Boja:";
                            s.ControlStyle.CssClass = "label";
                            s.AssociatedControlName = "Boja";
                        }
                    ).GetHtml()
            @Html.DevExpress().TextBox(
                        s =>
                        {
                            s.Name = "BojaDlake";
                            s.ControlStyle.CssClass = "editor";
                            s.Properties.ConvertEmptyStringToNull = true;
                            s.ShowModelErrors = true;
                        }
                    ).Bind(Model.BojaDlake).GetHtml()
        </div>
        <div class="line">
            @Html.DevExpress().Label(
                        s =>
                        {
                            s.Text = "Tip dlake:";
                            s.ControlStyle.CssClass = "label";
                            s.AssociatedControlName = "TipDlake";
                        }
                    ).GetHtml()
            @Html.DevExpress().TextBox(
                        s =>
                        {
                            s.Name = "TipDlake";
                            s.ControlStyle.CssClass = "editor";
                            s.Properties.ConvertEmptyStringToNull = true;
                            s.ShowModelErrors = true;
                        }
                    ).Bind(Model.TipDlake).GetHtml()
        </div>
        <div class="line">
            @Html.DevExpress().Label(
                        s =>
                        {
                            s.Text = "Visina [cm]:";
                            s.ControlStyle.CssClass = "label";
                            s.AssociatedControlName = "Visina";
                        }
                    ).GetHtml()
            @Html.DevExpress().TextBox(
                        s =>
                        {
                            s.Name = "Visina";
                            s.ControlStyle.CssClass = "editor";
                            s.Properties.ConvertEmptyStringToNull = true;
                            s.ShowModelErrors = true;
                        }
                    ).Bind(Model.Visina).GetHtml()
        </div>
        <div class="line">
            @Html.DevExpress().Label(
                        s =>
                        {
                            s.Text = "Težina [kg]:";
                            s.ControlStyle.CssClass = "label";
                            s.AssociatedControlName = "Tezina";
                        }
                    ).GetHtml()
            @Html.DevExpress().TextBox(
                        s =>
                        {
                            s.Name = "Tezina";
                            s.ControlStyle.CssClass = "editor";
                            s.Properties.ConvertEmptyStringToNull = true;
                            s.ShowModelErrors = true;
                        }
                    ).Bind(Model.Tezina).GetHtml()
        </div>
        <div class="line">
            @Html.DevExpress().Label(s =>
                {
                    s.Text = "Vlasnik:";
                    s.ControlStyle.CssClass = "label";
                    s.AssociatedControlName = "IdVlasnika";
                }).GetHtml()
            @Html.PartialOrNull("_VlasnikPsaComboBox", Model.IdVlasnika)
        </div>
        <div class="line">
            @Html.DevExpress().Label(s =>
               {
                   s.Text = "Odgajivač:";
                   s.ControlStyle.CssClass = "label";
                   s.AssociatedControlName = "IdOdgajivaca";
               }).GetHtml()
            @Html.PartialOrNull("_OdgajivacComboBox", Model.IdOdgajivaca)
        </div>
        <div class="line">
            @Html.DevExpress().Label(label =>
            {
                label.Text = "Otac:";
                label.ControlStyle.CssClass = "label";
                label.AssociatedControlName = "IdOca";
            }).GetHtml()
            @Html.PartialOrNull("_OtacPsaComboBox", Model.IdOca)
        </div>
        <div class="line">
            @Html.DevExpress().Label(label =>
            {
                label.Text = "Majka:";
                label.ControlStyle.CssClass = "label";
                label.AssociatedControlName = "IdMajke";
            }).GetHtml()
            @Html.PartialOrNull("_MajkaPsaComboBox", Model.IdMajke)
        </div>
        <div id="imageWrapper">
            @Html.DevExpress().Image(img =>
            {
                img.Name = "ImagePreview";
                img.ImageUrl = Model.SlikaPsa;
                img.Properties.AlternateText = "Slika psa";
                img.Width = Unit.Pixel(229);
                img.Height = Unit.Pixel(200);
            }).GetHtml()
            @Html.HiddenFor(x => x.SlikaPsa)
            @Html.DevExpress().UploadControl(upload =>
            {
                upload.Name = "Upload";
                upload.Width = Unit.Percentage(100);
                upload.ShowUploadButton = true;
                upload.ShowProgressPanel = true;
                upload.UploadButton.Text = "Pošalji";
                upload.ValidationSettings.Assign(PsiController.ImageValidationSettings);
                upload.CallbackRouteValues = new { Controller = "Psi", Action = "SacuvajSlikuPsa" };
                upload.ClientSideEvents.FileUploadComplete = "onFileUploadComplete";

            }).GetHtml()
        </div>
        <div class="line">
            @Html.DevExpress().Button(s =>
       {
           s.Name = "btnSave";
           s.Text = "Sačuvaj";
           s.ControlStyle.CssClass = "btnSave";
           s.ClientSideEvents.Click = "onSubmit";
       }).GetHtml()
        </div>
    </div>
}
@Html.Partial("_UnosKinologaPopup", new Kinolog())
<style>
    #editors
    {
        float: left;
        width: 400px;
    }
    #imageWrapper
    {
        width: 228px;
        margin-top: 340px;
        margin-left: 120px;
        border: 1px solid gray;
        padding: 5px 5px 5px 5px;
    }
</style>
